package javabase.thinkinjava.nio;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

import static javabase.thinkinjava.nio.GetChannel.BSIZE;

/**
 * @author fance
 * @date 18-4-30 上午9:03
 */
public class IntBufferDemo {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
        IntBuffer intBuffer = buffer.asIntBuffer();
        intBuffer.put(new int[] {1,2,3});
        System.out.println(intBuffer.get(2));
        intBuffer.put(2,100);
        intBuffer.flip();
        while (intBuffer.hasRemaining()) {
            int i = intBuffer.get();
            System.out.println(i);
        }
    }
}